cmake_minimum_required(VERSION 3.16)

project(qudpspectrum VERSION 1.0 LANGUAGES CXX)
set(CMAKE_INCLUDE_CURRENT_DIR ON)

set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)



find_package(QT NAMES Qt6 COMPONENTS Widgets Network REQUIRED)
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Widgets Network REQUIRED)
#FIX QT6 Link BUG in msys2 Qt static
if (QT_FEATURE_static STREQUAL "ON" AND WIN32 AND MINGW)
	set_property(TARGET harfbuzz::harfbuzz PROPERTY
		IMPORTED_IMPLIB ${harfbuzz_DIR}../../../libharfbuzz.dll.a )
endif()

include_directories(${PROJECT_SOURCE_DIR}/src)
include_directories(${PROJECT_SOURCE_DIR}/src/example)
set(PRJ_HEADERS
	dlgtest.h
	spectrum/specwidget.h
	spectrum/qtgui/agc_options.h
	spectrum/qtgui/bookmarks.h
	spectrum/qtgui/bookmarkstablemodel.h
	spectrum/qtgui/bookmarkstaglist.h
	spectrum/qtgui/demod_options.h
	spectrum/qtgui/dockrxopt.h
	spectrum/qtgui/freqctrl.h
	spectrum/qtgui/meter.h
	spectrum/qtgui/nb_options.h
	spectrum/qtgui/plotter.h
	udp/cudpreciever.h)

set(PRJ_SOURCES
	dlgtest.cpp
	main.cpp
	spectrum/specwidget.cpp
	spectrum/qtgui/agc_options.cpp
	spectrum/qtgui/bookmarks.cpp
	spectrum/qtgui/bookmarkstablemodel.cpp
	spectrum/qtgui/bookmarkstaglist.cpp
	spectrum/qtgui/demod_options.cpp
	spectrum/qtgui/dockrxopt.cpp
	spectrum/qtgui/freqctrl.cpp
	spectrum/qtgui/meter.cpp
	spectrum/qtgui/nb_options.cpp
	spectrum/qtgui/plotter.cpp
	udp/cudpreciever.cpp
)

set (PRJ_FORMS
	dlgtest.ui
	spectrum/specwidget.ui
	spectrum/qtgui/agc_options.ui
	spectrum/qtgui/demod_options.ui
	spectrum/qtgui/dockrxopt.ui
	spectrum/qtgui/nb_options.ui
)

if(CMAKE_SYSTEM_NAME MATCHES "Windows")
	include_directories($ENV{UHD_PKG_PATH}/include)
	link_directories($ENV{UHD_PKG_PATH}/lib)
endif()

if(CMAKE_SYSTEM_NAME MATCHES "Windows")
	message(${PROJECT_SOURCE_DIR})
	include_directories(${PROJECT_SOURCE_DIR}/../3rdlibs/fftw)
	 if( CMAKE_SIZEOF_VOID_P EQUAL 8 )
	link_directories(${PROJECT_SOURCE_DIR}/../3rdlibs/fftw/x64)
	set (FFT_LIB fftw3-3)
	else()
	link_directories(${PROJECT_SOURCE_DIR}/../3rdlibs/fftw/x86)
	set (FFT_LIB fftw3-3)
	endif()
else()
	set (FFT_LIB fftw3)
endif()


# ========================Exe========================

add_executable(qudpspectrum
	${PRJ_HEADERS}
	${PRJ_SOURCES}
	${PRJ_FORMS}
)

target_link_libraries(qudpspectrum PRIVATE
	uhd
	Qt${QT_VERSION_MAJOR}::Network
	Qt${QT_VERSION_MAJOR}::Widgets
	${FFT_LIB}

)


